package org.example.frw.exception;

import org.springframework.stereotype.Component;

import java.security.InvalidParameterException;

import static org.example.frw.exception.GlobalExceptionCode.INVALID_ARGUMENT_ERROR;
import static org.example.frw.exception.GlobalExceptionCode.SYSTEM_ERROR;

@Component
public class DefaultErrorCodeHandler implements ErrorCodeHandler {

    @Override
    public Integer getErrorCode(Throwable throwable) {
        if(throwable instanceof InvalidParameterException){
            return INVALID_ARGUMENT_ERROR.getCode();
        }
        return SYSTEM_ERROR.getCode();
    }

}
